package com.five.api.job;

import com.five.api.service.UserService;
import com.five.api.service.WalletRecordService;
import com.five.entity.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * @author: star
 * @Date: 2021-05-20 15:46
 *
 *  定时任务
 */
@Component("timedTaskJob")
public class TimedTaskJob {

    private Logger logger = LoggerFactory.getLogger(TimedTaskJob.class);

    @Autowired
    private WalletRecordService walletRecordService;

    public void execute() {
        Date date = new Date();
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        logger.info("定时器任务开启：删除未支付的钱包记录："+sf.format(date));
        System.err.println("定时器任务开启：删除未支付的钱包记录："+sf.format(date));

        walletRecordService.deleteWalletRecordByPayment();

        System.err.println("定时器任务结束：删除未支付的钱包记录："+sf.format(date));
        logger.info("定时器任务结束：删除未支付的钱包记录："+sf.format(date));
    }
}
